<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <div th:replace="common/fragment::leftmenu"></div>
        <!--End 左侧导航-->

        <!--头部信息-->
        <div th:replace="common/fragment::header"></div>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

             <!--   <div class="row">
                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-primary">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">今日收入</p>
                                    <p class="h3 text-white m-b-0">102,125.00</p>
                                </div>
                                <div class="pull-left">
                                    <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-currency-cny fa-1-5x"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-danger">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">用户总数</p>
                                    <p class="h3 text-white m-b-0">920,000</p>
                                </div>
                                <div class="pull-left">
                                    <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-account fa-1-5x"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-success">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">下载总量</p>
                                    <p class="h3 text-white m-b-0">34,005,000</p>
                                </div>
                                <div class="pull-left">
                                    <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-arrow-down-bold fa-1-5x"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-6 col-lg-3">
                        <div class="card bg-purple">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">新增留言</p>
                                    <p class="h3 text-white m-b-0">153 条</p>
                                </div>
                                <div class="pull-left">
                                    <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-comment-outline fa-1-5x"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>-->

                <div class="row">

                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <div class="toolbar-btn-action">
                                    <a class="btn btn-primary m-r-5" id="delete-log-btn"
                                       href="JavaScript:void (0);">
                                        <i class="mdi mdi-plus"></i>
                                        删除
                                    </a>
                                    <!--
                                    <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                                    <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                                    <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                                    -->
                                </div>
                            </div>
                            <div class="card-header">
                                <h4>日志记录</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>
                                                <label class="lyear-checkbox checkbox-primary">
                                                    <input type="checkbox" id="check-all">
                                                    <span></span>
                                                </label>
                                            </th>
                                            <th>序号</th>
                                            <th>操作者</th>
                                            <th>操作内容</th>
                                            <th>日期</th>
                                        </tr>
                                        </thead>
                                        <tbody th:each="log:${loglist}">
                                        <tr>
                                             <td>
                                                            <label class="lyear-checkbox checkbox-primary">
                                                                <input type="checkbox" name="ids[]" th:value="${log.id}">
                                                                <span></span>
                                                            </label>
                                                        </td>
                                            <td th:text="${logStat.index+1}"></td>

                                            <td th:text="${log.user.username}"></td>
                                            <td th:text="${log.content}"></td>
                                            <td th:text="${log.createTime}"></td>

                                        </tr>

                                        </tbody>
                                    </table>
                                    <!--分页标签-->
                                    <nav>
                                        <!--10页以内-->
                                        <th:block th:if="${totalPage lt 10}">
                                            <ul class="pagination pagination-sm">
                                                <!--后置箭头-->
                                                <li th:class="${currentPage>1?'':'disabled'}">
                                                    <span class="leftarrow" th:href="${currentPage}-1">
                                                        <span><i class="mdi mdi-chevron-left"></i></span>
                                                    </span>
                                                </li>

                                                <li th:class="${currentPage==1?'active':''} + ' label'" th:if="${totalPage ge 1}">
                                                    <a href="/sys/loglist.do?page=1">1</a></li>
                                                <li th:class="${currentPage==2?'active':''} + ' label'" th:if="${totalPage ge 2}">
                                                    <a href="/sys/loglist.do?page=2">2</a></li>
                                                <li th:class="${currentPage==3?'active':''} + ' label'" th:if="${totalPage ge 3}">
                                                    <a href="/sys/loglist.do?page=3">3</a></li>
                                                <li th:class="${currentPage==4?'active':''} + ' label'" th:if="${totalPage ge 4}">
                                                    <a href="/sys/loglist.do?page=4">4</a></li>
                                                <li th:class="${currentPage==5?'active':''} + ' label'" th:if="${totalPage ge 5}">
                                                    <a href="/sys/loglist.do?page=5">5</a></li>
                                                <li th:class="${currentPage==6?'active':''} + ' label'" th:if="${totalPage ge 6}">
                                                    <a href="/sys/loglist.do?page=6">6</a></li>
                                                <li th:class="${currentPage==7?'active':''} + ' label'" th:if="${totalPage ge 7}">
                                                    <a href="/sys/loglist.do?page=7">7</a></li>
                                                <li th:class="${currentPage==8?'active':''} + ' label'" th:if="${totalPage ge 8}">
                                                    <a href="/sys/loglist.do?page=8">8</a></li>
                                                <li th:class="${currentPage==9?'active':''} + ' label'" th:if="${totalPage ge 9}">
                                                    <a href="/sys/loglist.do?page=9">9</a></li>
                                                <li th:class="${currentPage==10?'active':''} + ' label'" th:if="${totalPage ge 10}">
                                                    <a href="/sys/loglist.do?page=10">10</a></li>

                                                <!--后置箭头-->
                                                <li th:class="${currentPage<totalPage?'':'disabled'}">
                                                    <span class="rightarrow" th:href="${currentPage}+1">
                                                        <span><i class="mdi mdi-chevron-right"></i></span>
                                                    </span>
                                                </li>
                                            </ul>

                                        </th:block>
                                        <!--超过10页-->
                                        <th:block th:if="${totalPage ge 10}">
                                            <ul class="pagination pagination-sm">
                                                <!--后置箭头-->
                                                <li th:class="${currentPage>1?'':'disabled'}">
                                                    <span class="leftarrow" th:href="${currentPage}-1">
                                                        <span><i class="mdi mdi-chevron-left"></i></span>
                                                    </span>
                                                </li>

                                                <!--首页-->
                                                <li th:class="${currentPage==1?'active':''} + ' label'" th:if="${totalPage ge 1}">
                                                    <a href="/sys/loglist.do?page=1">1</a></li>
                                                <li th:class="${currentPage==2?'active':''} + ' label'" th:if="${currentPage lt 3}">
                                                    <a href="/sys/loglist.do?page=2">2</a></li>
                                                <li th:class="${currentPage==3?'active':''} + ' label'" th:if="${currentPage lt 3}">
                                                    <a href="/sys/loglist.do?page=3">3</a></li>
                                                <li th:class="${currentPage==4?'active':''} + ' label'" th:if="${currentPage lt 3}">
                                                    <a href="/sys/loglist.do?page=3">4</a></li>

                                                <!--前省略号-->
                                                <li th:if="${befor_ellipsis eq true}"><span th:text="..."> </span></li>

                                                <!--中间分页current 前一页-->
                                                <li th:if="${mid eq true}">
                                                    <a th:href="'/sys/loglist.do?page='+${midb}" th:text="${currentPage}-1"></a>
                                                </li>
                                                <!--中间分页current-->
                                                <li th:class="${'active'}" th:if="${mid eq true}">
                                                    <a th:href="'/sys/loglist.do?page='+${currentPage}" th:text="${currentPage}"></a>
                                                </li>
                                                <!--中间分页current 后一页-->
                                                <li th:if="${mid eq true}">
                                                    <a th:href="'/sys/loglist.do?page='+${mida}" th:text="${currentPage}+1"></a>
                                                </li>

                                                <!--后省略号-->
                                                <li th:if="${after_ellipsis  eq true}"><span th:text="..."></span></li>

                                                <li th:class="${currentPage== last02?'active':''} + ' label'" th:if="${currentPage gt last02}">
                                                    <a th:href="'/sys/loglist.do?page='+last02" th:text="${last02}">2</a>
                                                </li>
                                                <li th:class="${currentPage== last01?'active':''} + ' label'" th:if="${currentPage  gt last02}">
                                                    <a th:href="'/sys/loglist.do?page='+last01" th:text="${last01}">2</a>
                                                <li th:class="${currentPage==last00?'active':''} + ' label'" th:if="${currentPage  gt last02}">
                                                <a th:href="'/sys/loglist.do?page='+last00" th:text="${last00}">2</a>
                                                <!--尾页-->
                                                <li th:class="${currentPage==totalPage?'active':''} + ' label'">
                                                    <a th:href="'/sys/loglist.do?page='+${totalPage}"  th:text="${totalPage}">10</a></li>

                                                <!--后置箭头-->
                                                <li th:class="${currentPage<totalPage?'':'disabled'}">
                                                    <span class="rightarrow" th:href="${currentPage}+1">
                                                        <span><i class="mdi mdi-chevron-right"></i></span>
                                                    </span>
                                                </li>
                                            </ul>

                                        </th:block>

                                    </nav>
                                    <!--分页标签结束-->
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<div th:replace="common/fragment::tail-script"></div>

<script>

    // 分页操作
    $(document).ready(function () {
        //左箭头点击
        $('.leftarrow').on('click', function () {
            console.log($(this).attr('href'))
            let jump = "/sys/loglist.do?page=" + $(this).attr('href')
            window.location.href = jump
        });


        //右箭头点击
        $('.rightarrow').on('click', function () {
            console.log($(this).attr('href'))
            let jump = "/sys/loglist.do?page=" + $(this).attr('href')
            window.location.href = jump
        });

        // 删除日志操作
        $('#delete-log-btn').on('click',function () {
            let ary = []
            $("input[name='ids[]']:checked").each(function (i,e) {
                let id = $(e).val()
                ary.push(id)

            })
            let data ={
                ary:ary
            }
            post_ajax('/sys/deletelog.ajax',data,'/sys/loglist.do')

        })
    });
</script>

</body>
</html>